import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';

import FX from 'fs-extra';

import Poseidon from '@nuogz/poseidon';
import Hades from '@nuogz/hades';


process.title = 'lol-vo-differ';
// eslint-disable-next-line no-unused-vars, no-debugger
process.on('unhandledRejection', (error, promise) => { G.fatal('进程', '未处理的拒绝', error); debugger; });


export const dirLib = dirname(fileURLToPath(import.meta.url));
export const dirApp = resolve(dirLib, '..');

export const dirConfig = resolve(dirApp, 'config');
export const dirLog = resolve(dirApp, 'log');

export const C = new Poseidon('', dirConfig);
export const G = new Hades(C.log.name, C.log.level, dirLog, C.log.option);
export const B = { db: null };

export const dirCache = resolve(dirApp, '_cache');
export const dirCacheManifest = resolve(dirCache, 'manifest');
export const dirCacheBundle = resolve(dirCache, 'bundle');
export const dirCacheExtract = resolve(dirCache, 'extract');
export const dirCacheAudio = resolve(dirCache, 'audio');
FX.ensureDirSync(dirCacheManifest);
FX.ensureDirSync(dirCacheBundle);
FX.ensureDirSync(dirCacheExtract);
FX.ensureDirSync(dirCacheAudio);

export const dirData = resolve(dirApp, 'data');
FX.ensureDirSync(dirData);
